package com.luych.toolbox.docker.service.sdk.container.model;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Optional;

public class DockerContainerChangesResult extends ArrayList<DockerContainerChangesResult.Change> {
    public static class Change {

        @JsonProperty("Path")
        private String path;

        @JsonProperty("Kind")
        private Kind kind;

        public String getPath() {
            return path;
        }

        public void setPath(String path) {
            this.path = path;
        }

        public Kind getKind() {
            return kind;
        }

        public void setKind(Kind kind) {
            this.kind = kind;
        }

        public enum Kind {
            ADDED(1), MODIFIED(1), DELETED(1);

            private final int value;

            Kind(int value) {
                this.value = value;
            }

            @JsonCreator
            public static Optional<Kind> instance(int value) {
                return Arrays.stream(Kind.values()).filter(v -> value == v.value).findFirst();
            }

            @JsonValue
            public int getValue() {
                return value;
            }
        }
    }
}
